package newPan3d.content.tree
{

			import _Pan3D.core.MathCore;
			import _Pan3D.program.Program3DManager;
			import _Pan3D.program.shaders.BuildTreeShader;
			
			import _me.Scene_data;
			
			import flash.display3D.Context3D;
			import flash.display3D.Program3D;
			import flash.events.Event;
			import flash.net.URLLoader;
			import flash.net.URLRequest;
			
			import robotleMvc.ui.tree.Tree3DSprite;
			
			import test.vo.StatVO;
			import test.zhuwei.TreeDisplay3DContainer;
			
			public class TreeLevel
			{
				private var _context3D:Context3D;
				private var _groundItem:Array;
				private var _bulidSpriteItem:Array;
				private var _display3DContainer:TreeDisplay3DContainer
				public function TreeLevel()
				{
					_display3DContainer=new TreeDisplay3DContainer();
					_context3D=Scene_data.context3D;
					loadBuildConfigXml();
					
				}
				private function loadBuildConfigXml():void
				{
					//加载地面XML列表
					
					var _loaderURL:URLRequest = new URLRequest(Scene_data.fileRoot+"build/"+"buildeditstatList.xml");
					var _scenexml:URLLoader=new URLLoader();
					_scenexml.load(_loaderURL);
					_scenexml.addEventListener(Event.COMPLETE, _loadGroundXmlOk);
					function _loadGroundXmlOk(event:Event):void
					{  
						//将XML数据传到MODEL进行解析。
						preasXml(XML(_scenexml.data));
						
					}
				}
				private function preasXml(_xml:XML):void
				{
					var _item:Array=MathCore.getSourcePro(_xml);
					var bulidItem:Array=new Array;
					for (var i:int=0; i < _item.length; i++)
					{
				
						if(!(_item[i].filetype)||Number(_item[i].filetype)==0)
						{
							var statVO:StatVO=new StatVO;
							statVO.et=_item[i].et;
							statVO.scale=_item[i].scale
							statVO.x=_item[i].x;
							statVO.y=_item[i].y;
							statVO.z=_item[i].z;
							statVO.type=_item[i].type;
							statVO.angle_y=_item[i].angley;
							statVO.id=i;
							
							statVO.name=_item[i].name;
							bulidItem.push(statVO);
						}
					}
					_bulidSpriteItem=new Array();
					for (var j:int=0; j < bulidItem.length; j++)
					{
						var tempVo:StatVO=bulidItem[j] as StatVO;
						//var display3DSprite:NewBuildDisplay3DSprite=new NewBuildDisplay3DSprite(_context3D);
						var display3DSprite:Tree3DSprite=new Tree3DSprite(_context3D);
						display3DSprite.url=tempVo.et
						display3DSprite.x=tempVo.x;
						display3DSprite.y=tempVo.y;
						display3DSprite.z=tempVo.z;
						display3DSprite.scale=tempVo.scale;
						display3DSprite.id=tempVo.id;
						display3DSprite.rotationY=tempVo.angle_y;
						_display3DContainer.addChild(display3DSprite);
						_bulidSpriteItem.push(display3DSprite);
						
					}
					//var treeShaderProgram3d:Program3D=Program3DManager.getInstance().getProgram(NewBuildShader.NEW_BUILD_SHADER);
					//var treeShaderProgram3d:Program3D=Program3DManager.getInstance().getProgram(BuildShader.BUILD_SHADER);
					var treeShaderProgram3d:Program3D=Program3DManager.getInstance().getProgram( BuildTreeShader.BUILD_TREE_SHADER);
					_display3DContainer.setProgram3D(treeShaderProgram3d);
				
					
				}
				public function upData():void
				{
					_display3DContainer.update();
				}
				public function get display3DContainer():TreeDisplay3DContainer
				{
					return _display3DContainer;
				}
				
			}
}